package com.neusoft.neuiotms.dcom.model.hn;

import java.util.ArrayList;
import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.ManyToMany;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.NotBlank;

import org.hibernate.validator.constraints.Length;

import com.neusoft.bizcore.web.jpa.model.AbstractAuditModel;
import com.neusoft.bizcore.web.jpa.model.Comment;
import com.neusoft.neuiotms.dcom.model.enums.HnInspectionCategory;
import com.neusoft.neuiotms.dcom.model.enums.HnInspectionItemDataType;
import com.neusoft.neuiotms.dcom.model.insurance.InsuranceInspectionTaskItem;

import lombok.Getter;
import lombok.Setter;

@Getter
@Setter
@Entity
@Table(name = "neuiot_inspection_item_hn")
@org.hibernate.annotations.Table(appliesTo = "neuiot_inspection_item_hn", comment = "海南巡检内容表")
public class HnInspectionItem extends AbstractAuditModel {

    private static final long serialVersionUID = 1171696094992221099L;

    @Enumerated(EnumType.STRING)
    @Column(length = 7, nullable = false)
    @Comment("varchar(7) NOT NULL COMMENT '巡检分类'")
    private HnInspectionCategory category;

    @NotBlank(message = "巡检项类别不能为空")
    @Length(max = 255, message = "巡检项类别不能超过{max}位")
    @Column(length = 255, nullable = false)
    @Comment("varchar(255) NOT NULL COMMENT '巡检项类别'")
    private String itemType;

    @NotBlank(message = "巡检项不能为空")
    @Length(max = 255, message = "巡检项不能超过{max}位")
    @Column(length = 255, nullable = false)
    @Comment("varchar(255) NOT NULL COMMENT '巡检项'")
    private String item;

    @Enumerated(EnumType.STRING)
    @Column(length = 32, nullable = false)
    @Comment("varchar(32) NOT NULL COMMENT '巡检项数据类型'")
    private HnInspectionItemDataType dataType;

    @Length(max = 255, message = "单位不能超过{max}位")
    @Column(length = 255, nullable = true)
    @Comment("varchar(255)  NULL COMMENT '单位类型'")
    private String unit;

    @Length(max = 1023, message = "候选值不能超过{max}位")
    @Column(length = 1023, nullable = true)
    @Comment("varchar(1023) NULL COMMENT '候选值'")
    private String candidateValue;

    @Length(max = 1023, message = "异常判断准则不能超过{max}位")
    @Column(length = 1023, nullable = true)
    @Comment("varchar(1023) NOT NULL COMMENT '异常判断准则'")
    private String rule;

    /** 是否禁用 **/
    private boolean disabled;

    @NotBlank(message = "维护人名称")
    @Length(max = 255, message = "维护人名称不能超过{max}位")
    @Column(length = 255, nullable = false)
    @Comment("varchar(255) NOT NULL COMMENT '维护人名称'")
    private String userName;

    @NotBlank(message = "维护人编码")
    @Length(max = 255, message = "维护人编码不能超过{max}位")
    @Column(length = 255, nullable = false)
    @Comment("varchar(255) NOT NULL COMMENT '维护人编码'")
    private String userCode;

    /** 排序 **/
    private int sort;

    @ManyToMany(mappedBy = "items")
    private List<HnInspectionPlan> plans = new ArrayList<>();

    @ManyToMany(mappedBy = "items")
    private List<HnInspectionHealthPlan> healthPlans = new ArrayList<>();

    @OneToMany(mappedBy = "item")
    private List<HnInspectionTaskItemValue> itemValues;

    @OneToMany(mappedBy = "item")
    private List<InsuranceInspectionTaskItem> inspectionItemValues;

    @OneToMany(mappedBy = "item")
    private List<HnInspectionHealthTaskItemValue> healthItemValues;

}
